package writtenTest;

public class Text1 {
    public static void main(String[] args) {
        /*
         * 、有一家超市，出售苹果和草莓。其中苹果 8 元/斤，草莓 13 元/斤。
         * 现在顾客 A 在超市购买了若干斤苹果和草莓，需要计算一共多少钱？
         * 请编写函数，对于 A 购买的水果斤数 (水果斤数为大于等于 0 的整数)，计算并返回所购买商品的总价
         */
            int weight = 9;
            int oneApplePrice = 8;
            int oneStrawberryPrice = 13;
            int appleWeight = 0;
            int strawberryWeight = 0;
            if(weight % 2 == 0){
                int tempWeight = weight / 2;
                appleWeight = tempWeight;
                strawberryWeight = tempWeight;
            }else{
                int tempWeight = (weight - 1) / 2;
                appleWeight = tempWeight + 1;
                strawberryWeight = tempWeight;
            }
            int applePrice = appleWeight * oneApplePrice;
            int strawberryPrice = strawberryWeight * oneStrawberryPrice;
            int sumPrice = applePrice + strawberryPrice;
            System.out.println("苹果重量为：" + appleWeight + "；苹果价格为：" + applePrice);
            System.out.println("草莓重量为：" + strawberryWeight + "；草莓价格为：" + strawberryPrice);
            System.out.println("总重量为：" + weight + "；总价格为：" + sumPrice);
        }

    }

